Introduction

This is the Developer's help file for the Mathcad Data Acquisition Component.

The Mathcad Data Acquisition Component (DAC) is an ActiveX control that allows you to acquire data from and send data to data acquisition devices installed on your computer. It's purpose is to allow a direct connection between Mathcad and any installed data acquisition devices by inserting the control into a scriptable object component (SOC). However, it may also be used in other programming environments, for example, in a Visual Basic project or on an Excel spreadsheet.

For the Mathcad Data Acquisition Component to work properly, your data acquisition devices must be properly installed in accordance with the instructions provided by manufacturer.

At this time, the control supports National Instruments E-Series data acquisition boards and PC cards and Measurement Computing (formerly ComputerBoards) devices. The control may also work with some non-E-Series NI devices (e.g. the DAQCard-500) but this is not completely supported.

This help file contains descriptions and code examples for all methods, properties and events associated with the control. The methods, properties and events are organized into individual book chapters.

The properties and methods of the control may be accessed and changed in various ways. You can use the form-like user interface, the properties dialog, or access properties and methods programmatically. The form-like user interface is the easiest way to access the properties and methods if you are using a visible instance of the control.

Connecting data from the DAC to Mathcad (or vice versa) requires that minimal scripting code be written. Example VBScript code is provided in the DAC script and several example files located in the \Samples\Dac subfolder of the Mathcad installation folder.

Minimum Requirements:

For the Data Acquisition Component to work, your data acquisition devices must be properly installed and Mathcad 2000 or higher must be installed. Of course, the minimum requirements of all required software (e.g Mathcad, NI-DAQ, or InstaCal) must also be satisfied.

Note: For National Instruments Devices, you must have NI-DAQ version 6.9.1 or higher installed on your computer for the DAC to work properly.


Overview

Data Acquisition Overview

General Overview:

The Mathcad Data Acquisition Component is an ActiveX control that interacts with data acquisition devices installed on your computer.

The Data Acquisition Component (DAC) is comprised of the data acquisition control embedded in a scriptable object component (SOC). The SOC is then saved to a user component MCM file. The user component is then available from the Insert Component dialog and can be inserted like any other component.

Thus, the DAC is not a native Mathcad component. As such, some scripting must be done to communicate with the embedded control. At a minimum, you must bind inputs and outputs of the SOC to data members of the embedded control.

When the DAC is initially inserted into a Mathcad worksheet it is set up for the default operation of single point analog input. The control properties can be changed by using the form-like user interface (UI), the Properties dialog, or programmatically. Any subsequent changes you make to the control's properties are saved when you close the Mathcad worksheet. So, the next time you open a worksheet containing a DAC the embedded control will be set up as it last was.

Example worksheets contained in the \Samples\DAC subfolder of the Mathcad installation folder illustrate how to use the DAC for single point and waveform analog input and output. These example files are an excellent starting point for creating your own worksheets.

Basic Operation:

The basic operation of the DAC is as follows. You specify the particular operation to be performed and the channels that it will be performed on. The channels are specified using the ChannelString property. When the ChannelString property is set, a Channel object is created for each channel specified. Interaction with the outside world is accomplished through the Data member of each Channel object.

When acquiring data the SOC should automatically recalculate whenever any of its output values change. The embedded control also raises the DataAcquired or DataSent events upon completion of data transfer. These events can be used for event handler routines within the SOC.

When sending data the SOC should pass an input value to the Data member of a Channel object and the Send method should be called in the Exec routine of the SOC. If you don't want to automatically send data when the SOC is recalculated leave the Send method out of the Exec routine and manually click the Send button on the UI.

Use of Triggers:

The wait for trigger feature is only applicable for waveform analog input operations.

In order to use the wait for trigger feature your device must support digital or analog triggers.

For National Instruments devices, digital triggers are applied at the PFI0 pin and are TTL transitions from either high-to-low or low-to-high. Analog triggers can be specified at PFI0 or an analog input channel and can be set for either a high-to-low or low-to-high transition and a specific voltage level can be set to trigger at. Only the first channel in the channel string may be the analog trigger input.

For Measurement Computing devices, digital triggers are applied at the"A/D Start Trigger In" pin and are TTL transitions from either high-to-low or low-to-high. Analog triggers are applied at the "Analog Trigger In" pin and can be set for either a high-to-low or low-to-high transition and a specific voltage level can set to trigger at.

To eliminate spurious triggers on analog input channels, make sure you read the trigger-related information in your device documentation.


Limitations

Limitations of the Mathcad Data Acquisition Control:

  1. For National Instruments devices, the control uses the default settings for the active device, i.e. input polarity and range and the input mode (e.g. referenced single ended, non-referenced single ended, or differential) . To configure the default setting for the devices installed on your computer, use the National Instruments Measurement & Automation Explorer.

  2. The use of National Instruments AMUX-64T multiplexer devices is not supported.

  3. Before you can access data members of the Channels collection, you must set the ChannelString property.

  4. The analog channel used for analog triggering is always the first channel in the channel string. If you edit the channel string, the order that the channels appear in the Channels collection may not agree with what is typed (e.g. if the channel string was 1:3 and then you edited it to be 0,1,2,3 channel zero would be added to the end of the channels collection and would actually be the fourth item in the collection). To clear the channel string set it equal to a blank string and then specify a new channel string. This will place members into the Channels collection in the order that they appear in the ChannelString.

  5. The values you receive from and send to the active device are in volts.

  6. The control does not implement all possible functions as it is intended to be used with Mathcad. For example, there is no wait for trigger feature for analog output because it is assumed that the results of a Mathcad calculation will trigger the analog output operation.

  7. Measurement Computing Devices: The DAC attempts to determine the A/D and D/A ranges supported by the device. For programmamable devices such as the PCI-DAS6402/16 this is functioning properly. For devices that do not allow setting the A/D and D/A range programmatically this feature is not working properly. If the range is not set right, conversion of the acquired data to voltage values is erroneous. This can be worked around by noting the range settings on your device and then selecting the proper range on the DAC properties dialog prior to acquiring data.

  8. If you are experiencing problems using National Instruments devices with the DAC, remember you must have NI-DAQ version 6.9.1 or higher installed on your computer.


MDAQ_DEVICE

MDAQDevice Class

The MDAQDevice class stores information related to all data acquisition devices installed on your computer.

The InstalledDevices collection is populated with an MDAQDevice object for each installed device as a result of a call to the QueryDevices Method. The QueryDevices Method is automatically called when the control is initialized so there should be no need to call it under normal circumstances. However, if you reconfigure devices while an instance of the control is running (e.g. change the device number) the QueryDevices method should be called to update information on the devices.

The MDAQDevice class has these members:

Member Description

Number As Integer

The number assigned to the device by the configuration utility.

DevType As String

The name of the device, e.g. DAQCard-500.

Manufacturer As String

The manufacturer of the device, e.g. National Instruments.

DevTypeCode As Long

The National Instruments device type code.

NumAIChannels As Long

The number of analog input channels that the device supports.

SupportsDIFFAI As Boolean

True if the device supports differential analog input.

SupportsNRSEAI As Boolean

True if the device supports non-referenced single ended analog input.

SupportsRSEAI As Boolean

True if the device supports referenced single ended analog input.

AllowedAIGains As Integer

For National Instruments devices, specifies the allowed gain values for the device. The values correspond to:

0: 1

1: 1, 10, and 100

2: 1, 2, 10, and 100

3: 1, 2, 5, 10, 20, 50, and 100

ChannelString As String

The channel string for the device.

InputResolution As Integer

The number of bits of resolution for the analog to digital converter.

SupportsAO As Boolean

True if the device supports analog output.

NumAOChannels As Long

The number of analog output channels.

OutputResolution As Integer

The number of bits of resolution for the digital to analog converter.

HasDigTrig As Boolean

True if the device supports digital triggers.

HasAnalogTrig As Boolean

True if the device supports analog triggers.

Supported As Boolean

True if the device is supported by the control.


MDAQ_CHANNEL

MDAQChannel Class

The MDAQChannel class stores information related to all channels in the channel string.

The Channels collection is populated with an MDAQChannel object for each channel in the channel string as a result of any change to the ChannelString property.

The MDAQChannel class members are Variants so that they may be accessed via VBScript and are described as follows:

Member Description

Number As Variant (Integer)

The actual channel number that the object refers to.

Data As Variant (Double)

Stores data related to the data transfer operation. For output, the data values are specified prior to sending data to the device. For input, this member stores the results of the data acquisition. The value is a scalar for single point operations and an array for waveform operations.

AIGain As Variant (Integer)

The analog input gain for the channel.

DeltaT As Variant (Double)

For waveform input or output operations, this value represents the actual time difference in seconds between analog to digital or digital to analog conversions. Usually, this number is the same as the inverse of the sample or update rate. However, if the device could not exactly match the particular rate this number will differ. Always check this value when performing waveform operations to ensure that actual time between samples or updates is known.


Acquire

Acquire Method

Reads data from the active data acquisition device.

Syntax

Variant = object.Acquire( )

The Acquire method syntax has these parts:

Part Description

object Required. A valid Mathcad Data Acquisition Control object.

Remarks

The Acquire method retrieves a reading, in volts, from every channel in the channel string. The data is stored in the Data member of the Channel object. The type of data returned depends on the IOType setting and is a scalar for single point operations and a vector for waveform operations.

The Acquire method returns 0 if successful or -1 if there was an error in at least one of the channels being acquired.

Example

Sub AcquireData()

Dim McadDAQ As AnalogIO

Dim vResult as Variant

'the next statement assumes there is a Mathcad Data Acquisition control called

' AnalogIO1 on Form1 of a VisualBasic project

Set McadDAQ = Form1.AnalogIO1

'set the channel string

McadDAQ.ChannelString = "0,1,3"

'set the IOFunction and IOType to input a single point from every channel in the channel string

McadDAQ.IOFunction = 0

McadDAQ.IOType = 0

'use the Acquire method to get the data

vResult = McadDAQ.Acquire

End Sub


Send

Send Method

Sends data to the active data acquisition device.

Syntax

Variant = object.Send( )

The Send method syntax has these parts:

Part Description

object Required. A valid Mathcad Data Acquisition Control object.

Remarks

The Send method sends the voltage value associated with a channel to all channels in the channel string. Each channel can have its own voltage value independent of the others. If the IOFunction property is set to send, the voltage values are remembered after the document containing the control is closed.

The data to be sent is stored in the Data member of the Channel object. The type of data sent depends on the IOType setting and is a scalar for single point operations and a vector for waveform operations.

The Send method returns 0 if successful or -1 if there was an error in at least one of the channels having data sent to it.

Example

Sub SendData()

Dim McadDAQ As AnalogIO

Dim vResult as Variant

'the next statement assumes there is a Mathcad Data Acquisition control called

' AnalogIO1 on Form1 of a VisualBasic project

Set McadDAQ = Form1.AnalogIO1

'set the channel string

McadDAQ.ChannelString = "0,1"

'set the IOFunction and IOType to output a single point from every channel

' in the channel string

McadDAQ.IOFunction = 1

McadDAQ.IOType = 0

'set the channel data to send

McadDAQ.Channels("0").Data = 1.5#

McadDAQ.Channels("1").Data = 4.25#

'use the Send method to send the data to the output channels

vResult = McadDAQ.Send

End Sub


QueryDevices

QueryDevices Method

Retrieves information on installed and configured data acquisition devices.

Syntax

Variant = object.QueryDevices( )

The QueryDevices method syntax has these parts:

Part Description

object Required. A valid Mathcad Data Acquisition Control object.

Remarks

The QueryDevices method is called when the control initializes and looks for installed and confugured data acquisition devices on your computer. The results are stored in the InstalledDevices collection. The QueryDevices method returns 0 if there was at least one supported device installed on your computer and -1 otherwise.

Example

Sub GetDeviceInfo()

Dim McadDAQ As AnalogIO

Dim vResult as Variant

'the next statement assumes there was a Mathcad Data Acquisition control called

' AnalogIO1 on Form1 of a VisualBasic project

Set McadDAQ = Form1.AnalogIO1

vResult = McadDAQ.QueryDevices

End Sub


ShowAbout

ShowAbout Method

Shows the about box for the control.

Syntax

object.ShowAbout( )

The ShowAbout method syntax has these parts:

Part Description

object Required. A valid Mathcad Data Acquisition Control object.

Remarks

The ShowAbout method is useful for determining the version number of the control. The version number of the control can also be determined by navigating to the file "MathcadDAQ.ocx" in Windows Explorer, right-clicking on the file and selecting "Properties", and then clicking on the "Version" tab of the properties dialog.

If you encounter any errors when using this control please notify MathSoft technical support and provide a complete description of the problem and the version number of the control so that the problem can be logged in our database and fixed in a future release.

Example

Sub ShowAbout()

Dim McadDAQ As AnalogIO

'the next statement assumes there is a Mathcad Data Acquisition control called

' AnalogIO1 on Form1 of a VisualBasic project

Set McadDAQ = Form1.AnalogIO1

McadDAQ.ShowAboutBox

End Sub


ActiveDevice

ActiveDevice Property

Returns or sets the active data acquisition device.

Syntax

Variant = object.ActiveDevice( )

object.ActiveDevice = vNewValue

The ActiveDevice property syntax has these parts:

Part Description

object Required. A valid Mathcad Data Acquisition Control object.

vNewValue Variant (Integer). The number of the device to make the active device.

Remarks

The ActiveDevice property is used to determine or specify the device that will be used for all subsequent operations. The numbers for devices installed on your computer are assigned using the National Instruments Measurement & Automation Explorer. Valid ranges are from 1 to 16 inclusive.

If an invalid number is specified, e.g. a non-existent device or a non-numeric value, the value reverts to a known good value.

Example

Sub SetGetActiveDevice()

Dim McadDAQ As AnalogIO

Dim vResult as Variant

'the next statement assumes there was a Mathcad Data Acquisition control called

' AnalogIO1 on Form1 of a VisualBasic project

Set McadDAQ = Form1.AnalogIO1

'set the new active device

McadDAQ.ActiveDevice = 2%

vResult = McadDAQ.ActiveDevice

MsgBox "The ActiveDevice is now: " & CStr(vResult)

End Sub


ADRange

Measurement Computing Devices Only. Returns or sets the voltage range used for analog to digital conversions on the active device.

Syntax

Variant = object.ADRange( )

object.ADRange = vNewValue

The ADRange property syntax has these parts:

Part Description

object Required. A valid Mathcad Data Acquisition Control object.

vNewValue Variant (Integer). See the specifications for your device to determine the voltage range and corresponding range code.

Remarks

If the device is not software configurable, this value is ignored.


DARange

Measurement Computing Devices Only. Returns or sets the voltage range used for digital to analog conversions on the active device.

Syntax

Variant = object.DARange( )

object.DARange = vNewValue

The DARange property syntax has these parts:

Part Description

object Required. A valid Mathcad Data Acquisition Control object.

vNewValue Variant (Integer). See the specifications for your device to determine the voltage range and corresponding range code.

Remarks

If the device is not software configurable, this value is ignored.


ChannelString

ChannelString Property

Returns or sets the channels that subsequent operations are performed on.

Syntax

Variant = object.ChannelString( )

object.ChannelString = vNewValue

The ChannelString property syntax has these parts:

Part Description

object Required. A valid Mathcad Data Acquisition Control object.

vNewValue Variant (String). The new channel string.

Remarks

The ChannelString property is used to determine or specify the channels that all subsequent operations will be performed on.

Individual channels are specified using a comma separating the channels, e.g. "1,3,5" for channels 1, 3, and 5.

A continuous range of channels may be specified using a colon to separate the lower and upper bounds, e.g. "0:4" for channels 0, 1, 2, 3, and 4 or "5:2" for channels 5, 4, 3, and 2.

The ChannelString property must be set before any operation can be performed. Upon specifying the ChannelString property members of the Channels collection are created.

Operations are performed on the channels according to their order in the Channels collection.

Example

Sub SetGetChanString()

Dim McadDAQ As AnalogIO

Dim vResult as Variant

'the next statement assumes there is a Mathcad Data Acquisition control called

' AnalogIO1 on Form1 of a VisualBasic project

Set McadDAQ = Form1.AnalogIO1

'set the new channel string

McadDAQ.ChannelString = "0:4"

vResult = McadDAQ.ChannelString

MsgBox "The new ChannelString is: " & Cstr(vResult)

End Sub


Channels Collection

Returns a collection containing MDAQChannel members.

Syntax

Channel = object.Channels(index)

The Channels collection syntax has these parts:

Part Description

object Required. A valid Mathcad Data Acquisition Control object.

index Required. A string or integer value representing the channel object to return. Specifying a string for index returns information for the channel having the same name. Specifying an integer for index returns that item of the collection.

Channel Required. MDAQChannel. A variable used to store the collection member.

Remarks

The Channels collection is composed of MDAQChannel class objects. The collection is accessed to set or retrieve data for the particular operation. If a non-existent channel index is specified a VB run time error occurs.

Example

Sub GetChannelObject()

Dim McadDAQ As AnalogIO

Dim MyChannel as MDAQChannel

'the next statement assumes there is a Mathcad Data Acquisition control called

' AnalogIO1 on Form1 of a VisualBasic project

Set McadDAQ = Form1.AnalogIO1

'get the information for channel 0

Set MyChannel = McadDAQ.Channels("0")

If IsArray(MyChannel.Data) Then

MsgBox "Channel 0 contains array data"

Else

MsgBox "Channel 0 contains scalar data"

End If

End Sub


InstalledDevices

InstalledDevices Collection

A collection of information on all installed data acquisition devices. Members of the collection are MDAQDevice class objects.

Syntax

Device = object.InstalledDevices( index)

The InstalledDevices collection syntax has these parts:

Part Description

object Required. A valid Mathcad Data Acquisition Control object.

index Required. A string or integer value representing the device object to return. Specifying a string for index returns information for the device having the same number. Specifying an integer for index returns that item of the collection. A particular device may not necessarily have the same name as its index in the collection.

Device Required. MDAQDevice. A variable used to hold the device member.

Remarks

The InstalledDevices collection is populated when the control is initialized or after a call to the QueryDevices method.

Example

Sub GetDeviceObject()

Dim McadDAQ As AnalogIO

Dim MyDevice as MDAQDevice

'the next statement assumes there is a Mathcad Data Acquisition control called

' AnalogIO1 on Form1 of a VisualBasic project

Set McadDAQ = Form1.AnalogIO1

'get the information for device 1

Set MyDevice = McadDAQ.InstalledDevices("1")

If MyDevice.HasDigTrig Then

MsgBox "Device 1 supports digital triggers"

Else

MsgBox "Device 1 does not support digital triggers"

End If

End Sub


IOFunction

IOFunction Property

Returns or sets function of the data acquisition device.

Syntax

Variant = object.IOFunction( )

object.IOFunction = vNewValue

The IOFunction property syntax has these parts:

Part Description

object Required. A valid Mathcad Data Acquisition Control object.

vNewValue Variant (Integer). The function to perform. Set to 0 for analog input and 1 for analog output.

Remarks

The IOFunction property is used to determine or specify the function of the active device. Valid values for the new value are 0 for analog input and 1 for analog output.

Example

Sub SetGetIOFunction()

Dim McadDAQ As AnalogIO

Dim vResult as Variant

'the next statement assumes there is a Mathcad Data Acquisition control called

' AnalogIO1 on Form1 of a VisualBasic project

Set McadDAQ = Form1.AnalogIO1

'set the new active device

McadDAQ.IOFunction = 0%

vResult = McadDAQ.IOFunction

MsgBox "The IOFunction is now: " & CStr(vResult)

End Sub


IOType

IOType Property

Returns or sets type of operation the data acquisition device will perform.

Syntax

Variant = object.IOType( )

object.IOType = vNewValue

The IOType property syntax has these parts:

Part Description

object Required. A valid Mathcad Data Acquisition Control object.

vNewValue Variant (Integer). The type of operation to perform. Set to 0 for single point and 1 for waveform.

Remarks

The IOType property is used to determine or specify the type of operation the active device will perform. Valid values for the new value are 0 for single point and 1 for waveform.

Single point operations send or receive a single point of data to or from all channels in the ChannelString.

Waveform input operations acquire the same number of data points from all channels in the ChannelString. Waveform output is only sent to the first analog output channel in the channel string.

For input operations you must specify the Rate and NumSamples properties (or use their default values). For output operation you must specify the Rate and the NumIterations properties (or use their default values) and the number of samples is determined from the size of the data in the channels Data member.

Example

Sub SetGetIOType()

Dim McadDAQ As AnalogIO

Dim vResult as Variant

'the next statement assumes there is a Mathcad Data Acquisition control called

' AnalogIO1 on Form1 of a VisualBasic project

Set McadDAQ = Form1.AnalogIO1

'set the new active device

McadDAQ.IOType = 1%

vResult = McadDAQ.IOType

MsgBox "The IOType is now: " & CStr(vResult)

End Sub


NumSamples

NumSamples Property

Returns or sets the number of samples to retrieve during waveform acquisition.

Syntax

Variant = object.NumSamples()

object.NumSamples = vNewValue

The NumSamples property syntax has these parts:

Part Description

object Required. A valid Mathcad Data Acquisition Control object.

vNewValue Required. Variant (Integer). The number of samples to acquire.

Remarks

During waveform data acquisition NumSamples of data points are acquired form each channel in the channel string.

Example

Sub GetWaveform()

Dim McadDAQ As AnalogIO

Dim lTemp as Long

'the next statement assumes there is a Mathcad Data Acquisition control called

' AnalogIO1 on Form1 of a VisualBasic project

Set McadDAQ = Form1.AnalogIO1

'set the channel string to acquire from channels 0 and 3

McadDAQ.ChannelString = "0,3"

'set the IOFunction to input

McadDAQ.IOFunction = 0&

'set the IOType to waveform

McadDAQ.IOType = 1&

'set the number of samples to acquire for all channels

McadDAQ.NumSamples = 1000%

'set the sample rate

McadDAQ.Rate = 10000%

'acuire the data

McadDAQ.Acquire

'See if the right number of samples was acquired

lTemp = UBound(McadDAQ.Channels("0").Data) + 1

MsgBox CStr(lTemp) & " samples were acquired"

End Sub


SampleRate

Rate Property

Returns or sets the rate, in samples per second, at which analog to digital or digital to analog conversions take place.

Syntax

Variant = object.Rate()

object.Rate = vNewValue

The Rate property syntax has these parts:

Part Description

object Required. A valid Mathcad Data Acquisition Control object.

vNewValue Required. Variant (Double). The new sample or transfer rate.

Remarks

The Rate property has dual usage. For input operations it specifies the rate at which analog to digital conversions take place. For output operations it specifies the rate at which digital to analog conversions take place.

The time between samples or updates, in seconds, is usually the inverse of the Rate property. However, this may not always be the case. To determine the actual time between samples that was used for the data transfer operation, get the DeltaT property of the channel item.

Example

Sub GetWaveform()

Dim McadDAQ As AnalogIO

Dim lTemp as Long

'the next statement assumes there is a Mathcad Data Acquisition control called

' AnalogIO1 on Form1 of a VisualBasic project

Set McadDAQ = Form1.AnalogIO1

'set the channel string to acquire from channels 0 and 3

McadDAQ.ChannelString = "0,3"

'set the IOFunction to input

McadDAQ.IOFunction = 0&

'set the IOType to waveform

McadDAQ.IOType = 1&

'set the number of samples to acquire for all channels

McadDAQ.NumSamples = 1000%

'set the sample rate in samples per second

McadDAQ.Rate = 10000%

'acuire the data

McadDAQ.Acquire

'See if the right number of samples was acquired, zero base assumed

lTemp = UBound(McadDAQ.Channels("0").Data) + 1

MsgBox CStr(lTemp) & " samples were acquired"

End Sub


WaitForTrigger

WaitForTrigger Property

Returns or sets a variable that tells the control whether or not to wait for a trigger before starting waveform acquisition.

Syntax

Variant = object.WaitForTrigger()

object.WaitForTrigger = vNewValue

The WaitForTrigger property syntax has these parts:

Part Description

object Required. A valid Mathcad Data Acquisition Control object.

vNewValue Required. Variant (Integer). Set to 1 to wait for a trigger or 0 for not to wait.

Remarks

The WaitForTrigger property, as its name implies, tells the control whether or not to wait for a trigger before starting waveform acquisition. You must specify the trigger properties using the TriggerType, TriggerEdge, TriggerSource, and TriggerLevel properties as appropriate. The default trigger is a digital trigger at the PFI0 pin.

If an invalid value, e.g. other than 0 or 1 or non-numeric, is specified for the property it will default back to 0.

Example

Sub GetWaveformOnTrigger()

Dim McadDAQ As AnalogIO

Dim lTemp as Long

'the next statement assumes there is a Mathcad Data Acquisition control called

' AnalogIO1 on Form1 of a VisualBasic project

Set McadDAQ = Form1.AnalogIO1

'set the channel string to acquire from channel 1

McadDAQ.ChannelString = "1"

'set the IOFunction to input

McadDAQ.IOFunction = 0&

'set the IOType to waveform

McadDAQ.IOType = 1&

'set the number of samples to acquire for all channels

McadDAQ.NumSamples = 1000%

'set the sample rate in samples per second

McadDAQ.Rate = 10000%

'set trigger related information

McadDAQ.WaitForTrigger = 1%

'Set up for low-to-high analog trigger of 2.5 Volts at the PFI0 pin

McadDAQ.TriggerType = 1%

McadDAQ.TriggerSource = 0&

McadDAQ.TriggerEdge = 0&

McadDAQ.TriggerLevel = 2.5#

'acquire the data

McadDAQ.Acquire

'See if the right number of samples was acquired, zero base assumed

On Error Resume Next

lTemp = UBound(McadDAQ.Channels("1").Data) + 1

If Err.Number = 0 Then

MsgBox CStr(lTemp) & " samples were acquired"

Else

MsgBox "Acquisition Error"

End If

End Sub


ShowErrors

ShowErrors Property

Returns or sets a variable that tells the control whether or not to generate NI-DAQ error messages.

Syntax

Variant = object.ShowErrors()

object.ShowErrors = vNewValue

The ShowErrors property syntax has these parts:

Part Description

object Required. A valid Mathcad Data Acquisition Control object.

vNewValue Required. Variant (Integer). Set to 1 to show or 0 for not to show NI-DAQ error messages.

Remarks

If the ShowErrors property is set to 0, no error messages will be generated if inappropriate properties are specified for the active device, for example specifying an out of range channel number in the channel string. This is done so as not to interrupt calculation flow in Mathcad.

If you think all properties are specified correctly for the particular operation being performed but nothing is happening, set the ShowErrors property to 1 and try the operation again.

Example

Sub SetShowErrors()

Dim McadDAQ As AnalogIO

'the next statement assumes there is a Mathcad Data Acquisition control called

' AnalogIO1 on Form1 of a VisualBasic project

Set McadDAQ = Form1.AnalogIO1

'set the ShowErrors property

McadDAQ.ShowErrors = 1%

End Sub


NumIterations

NumIterations Property

Returns or sets the number of times to repeat a waveform output.

Syntax

Variant = object.NumIterations()

object.NumIterations = vNewValue

The NumIterations property syntax has these parts:

Part Description

object Required. A valid Mathcad Data Acquisition Control object.

vNewValue Required. Variant (Integer). The number of times to repeat a waveform output.

Remarks

During waveform data output NumIterations of the waveform are sent to the output channel. The minimum value is one. This property is useful for generating a waveform for a long time. For example, instead of generating one thousand cycles of a sine wave, you could generate one cycle and repeat it one thousand times. The latter method can be done specifying less data points.

Example

Sub SendWaveform()

Dim McadDAQ As AnalogIO

Dim i as Integer

Dim vData(99) as Variant

'the next statement assumes there is a Mathcad Data Acquisition control called

' AnalogIO1 on Form1 of a VisualBasic project

Set McadDAQ = Form1.AnalogIO1

'set the channel string to send to channel 0

'Note: you can only send waveform data to one channel

McadDAQ.ChannelString = "0"

'set the IOFunction to output

McadDAQ.IOFunction = 1&

'set the IOType to waveform

McadDAQ.IOType = 1&

'Generate the data to send to the output channel

For i = 0 To 99

vData(i) = sin(i * 2 * 3.14159/100)

Next

'set the channel data

McadDAQ.Channels("0").Data = vData

'set the number of iterations

McadDAQ.NumIterations = 10%

'set the update rate

McadDAQ.Rate = 100%

'generate the waveform

McadDAQ.Send

End Sub


TrigEdge

TriggerEdge Property

Returns or sets the trigger edge transition for analog trigger operations.

Syntax

Variant = object.TriggerEdge()

object.TriggerEdge = vNewValue

The TriggerEdge property syntax has these parts:

Part Description

object Required. A valid Mathcad Data Acquisition Control object.

vNewValue Required. Variant (Long). Set to 0 for low-to-high transition or 1 for high-to-low transition.

Remarks

The TriggerEdge property is used in conjunction with the TriggerLevel property for analog trigger operations and is ignored for digital triggers.

If an invalid value, e.g. other than 0 or 1 or non-numeric, is specified for the property it will default back to 0.

Example

Sub GetWaveformOnTrigger()

Dim McadDAQ As AnalogIO

Dim lTemp as Long

'the next statement assumes there is a Mathcad Data Acquisition control called

' AnalogIO1 on Form1 of a VisualBasic project

Set McadDAQ = Form1.AnalogIO1

'set the channel string to acquire from channel 1

McadDAQ.ChannelString = "1"

'set the IOFunction to input

McadDAQ.IOFunction = 0&

'set the IOType to waveform

McadDAQ.IOType = 1&

'set the number of samples to acquire for all channels

McadDAQ.NumSamples = 1000%

'set the sample rate in samples per second

McadDAQ.Rate = 10000%

'set trigger related information

McadDAQ.WaitForTrigger = 1%

'Set up for low-to-high analog trigger of 2.5 Volts at the PFI0 pin

McadDAQ.TriggerType = 1%

McadDAQ.TriggerSource = 0&

McadDAQ.TriggerEdge = 0&

McadDAQ.TriggerLevel = 2.5#

'acquire the data

McadDAQ.Acquire

'See if the right number of samples was acquired, zero base assumed

On Error Resume Next

lTemp = UBound(McadDAQ.Channels("1").Data) + 1

If Err.Number = 0 Then

MsgBox CStr(lTemp) & " samples were acquired"

Else

MsgBox "Acquisition Error"

End If

End Sub


TrigLevel

TriggerLevel Property

Returns or sets the analog trigger level.

Syntax

Variant = object.TriggerLevel()

object.TriggerLevel = vNewValue

The TriggerLevel property syntax has these parts:

Part Description

object Required. A valid Mathcad Data Acquisition Control object.

vNewValue Required. Variant (Double). The analog trigger level in volts.

Remarks

The TriggerLevel property is used to specify the level of the analog trigger.

If an invalid value, e.g. non-numeric, is specified for the property it will default to 0 volts.

Example

Sub GetWaveformOnTrigger()

Dim McadDAQ As AnalogIO

Dim lTemp as Long

'the next statement assumes there is a Mathcad Data Acquisition control called

' AnalogIO1 on Form1 of a VisualBasic project

Set McadDAQ = Form1.AnalogIO1

'set the channel string to acquire from channel 1

McadDAQ.ChannelString = "1"

'set the IOFunction to input

McadDAQ.IOFunction = 0&

'set the IOType to waveform

McadDAQ.IOType = 1&

'set the number of samples to acquire for all channels

McadDAQ.NumSamples = 1000%

'set the sample rate in samples per second

McadDAQ.Rate = 10000%

'set trigger related information

McadDAQ.WaitForTrigger = 1%

'Set up for low-to-high analog trigger of 2.5 Volts at the PFI0 pin

McadDAQ.TriggerType = 1%

McadDAQ.TriggerSource = 0&

McadDAQ.TriggerEdge = 0&

McadDAQ.TriggerLevel = 2.5#

'acquire the data

McadDAQ.Acquire

'See if the right number of samples was acquired, zero base assumed

On Error Resume Next

lTemp = UBound(McadDAQ.Channels("1").Data) + 1

If Err.Number = 0 Then

MsgBox CStr(lTemp) & " samples were acquired"

Else

MsgBox "Acquisition Error"

End If

End Sub


TrigSource

TriggerSource Property

Returns or sets the trigger source.

Syntax

Variant = object.TriggerSource()

object.TriggerSource = vNewValue

The TriggerSource property syntax has these parts:

Part Description

object Required. A valid Mathcad Data Acquisition Control object.

vNewValue Required. Variant (Long). Set to 0 for PFI0 or 1 for the analog input channel.

Remarks

The TriggerSource property is used to specify the source of the analog trigger. Digital triggers always use the PFI0 pin for the trigger input. If the TriggerType is analog then you can specify that either PFI0 pin or the analog input channel be the source of the trigger. Analog triggers also require that the TriggerLevel and TriggerEdge properties be specified.

If the analog input channel is the source of the trigger and there are multiple channels in the channel string, the first channel in the channels collection is the source of the trigger.

If an invalid value, e.g. other than 0 or 1 or non-numeric, is specified for the property it will default back to 0.

Example

Sub GetWaveformOnTrigger()

Dim McadDAQ As AnalogIO

Dim lTemp as Long

'the next statement assumes there is a Mathcad Data Acquisition control called

' AnalogIO1 on Form1 of a VisualBasic project

Set McadDAQ = Form1.AnalogIO1

'set the channel string to acquire from channel 1

McadDAQ.ChannelString = "1"

'set the IOFunction to input

McadDAQ.IOFunction = 0&

'set the IOType to waveform

McadDAQ.IOType = 1&

'set the number of samples to acquire for all channels

McadDAQ.NumSamples = 1000%

'set the sample rate in samples per second

McadDAQ.Rate = 10000%

'set trigger related information

McadDAQ.WaitForTrigger = 1%

'Set up for low-to-high analog trigger of 2.5 Volts at the PFI0 pin

McadDAQ.TriggerType = 1%

McadDAQ.TriggerSource = 0&

McadDAQ.TriggerEdge = 0&

McadDAQ.TriggerLevel = 2.5#

'acquire the data

McadDAQ.Acquire

'See if the right number of samples was acquired, zero base assumed

On Error Resume Next

lTemp = UBound(McadDAQ.Channels("1").Data) + 1

If Err.Number = 0 Then

MsgBox CStr(lTemp) & " samples were acquired"

Else

MsgBox "Acquisition Error"

End If

End Sub


TrigType

TriggerType Property

Returns or sets the type of trigger to be used.

Syntax

Variant = object.TriggerType()

object.TriggerType = vNewValue

The TriggerType property syntax has these parts:

Part Description

object Required. A valid Mathcad Data Acquisition Control object.

vNewValue Required. Variant (Integer). Set to 0 for digital or 1 for analog.

Remarks

The TriggerType property specifies if digital or analog triggers are to be used. If analog trigger is specified the the TriggerType, TriggerEdge, TriggerSource, and TriggerLevel properties should also be specified as appropriate.

If an invalid value, e.g. other than 0 or 1 or non-numeric, is specified for the property it will default back to 0.

Example

Sub GetWaveformOnDigitalTrigger()

Dim McadDAQ As AnalogIO

Dim lTemp as Long

'the next statement assumes there is a Mathcad Data Acquisition control called

' AnalogIO1 on Form1 of a VisualBasic project

Set McadDAQ = Form1.AnalogIO1

'set the channel string to acquire from channel 1

McadDAQ.ChannelString = "1"

'set the IOFunction to input

McadDAQ.IOFunction = 0&

'set the IOType to waveform

McadDAQ.IOType = 1&

'set the number of samples to acquire for all channels

McadDAQ.NumSamples = 1000%

'set the sample rate in samples per second

McadDAQ.Rate = 10000%

'set trigger related information

McadDAQ.WaitForTrigger = 1%

'Set up for digital trigger at the PFI0 pin

McadDAQ.TriggerType = 0%

'acquire the data

McadDAQ.Acquire

'See if the right number of samples was acquired, zero base assumed

On Error Resume Next

lTemp = UBound(McadDAQ.Channels("1").Data) + 1

If Err.Number = 0 Then

MsgBox CStr(lTemp) & " samples were acquired"

Else

MsgBox "Acquisition Error"

End If

End Sub


DataAcquired

DataAcquired Event

This event is raised after all data for the specified operation has been acquired from the active device.

The purpose of the event is to allow for an event handler routine.


DataSent

DataSent Event

This event is raised after all data for the specified operation has been sent to the active device.

The purpose of the event is to allow for an event handler routine.